<div class="content" >
    <h1>Grade Override</h1>

    <p>Use this form to
    <a target=_blank href="https://submitty.org/instructor/grade_override">
    override the total score
    <i style="font-style:normal;" class="fa-question-circle"></i></a>
    for a student on a specific assignment or test.

    <br>
    <br>

    This is useful for recording the grade on a makeup exam that used a different rubric, <br>
    or to assign a grade in extenuating circumstances; e.g., unable to submit work on time, plagiarism, etc.
    </p>

    <br>
    <br>

    <form id="gradeOverrideForm" method="post" enctype="multipart/form-data" action="" onsubmit="return updateGradeOverride($(this));">
        <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
        <input type="hidden" name="option" value="-1" />
        <div class="option">
            <div class="option"><label for="g_id">Select Gradeable:</label><br>
                <select name="g_id" id="g_id" style="margin-top: 10px; width: 50%">
                    <option disabled selected value> -- select an option -- </option>
                    {% for index, value in gradeables %}
                        <option value="{{value['g_id']}}" >{{ value['g_title'] }}</option>
                    {% endfor %}
                </select>
                <button type="button" class="btn btn-primary" style="margin-top: 10px" onclick="loadOverriddenGrades($('#g_id').val())"> Apply Changes </button>
            </div>
        </div>
        <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
        <fieldset class="single-student">
            <legend class="option-title">Single Student Entry<br></legend>
            <label for="user_id">Student ID:
                <input class="option-input" type="text" name="user_id" id="user_id" >
            </label>
            <label for="marks">New total score:
                <input class="option-input" type="text" name="marks" id="marks"  >
            </label>
            <label for="comment">Comments (optional)
                <textarea name="comment" id="comment" class="option-input" type="text" ></textarea>
            </label>
        </fieldset>
        <input class="btn btn-primary" type="submit" value="Submit" >
        <div id="load-overridden-grades" align="center">
        {# This is a data table #}
            <table id="my_table" class="table table-striped table-bordered persist-area" style="width:70%" align="center">
                <div class="option-title" id="title"></div>
                <div>
                    <caption />
                    <thead>
                        <th>Student ID</th>
                        <th>First Name</th>
                        <th>Last Name</th>
                        <th>Marks</th>
                        <th>Comments</th>
                        <th>Delete</th>
                    </thead>
                </div>
            </table>
    </div>
    </form>
</div>
<script>
    $("#user_id").autocomplete({
        source: {{ student_full|raw }}
    });
</script>
